package com.cya.cyaproducts;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.cya.entities.Product;
import com.cya.imageloader.ImageLoader;

public class DetailActivity extends Activity{
	public ImageLoader imgLoader;

	@Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.detail);

        Bundle receiveBundle = this.getIntent().getExtras();
		String id = receiveBundle.getString("id");
		
		
        String result_string = Crawler.getInstance().getProductById(Integer.parseInt(id));
        Product product = LibJsonParse.getProduct(result_string);
        
        TextView product_name = (TextView)findViewById(R.id.detail_name);
        product_name.setText(product.Name);
        
        TextView product_desc = (TextView)findViewById(R.id.detail_desc);
        product_desc.setText(product.Content);
		
		TextView product_short_desc = (TextView)findViewById(R.id.detail_short_desc);
		product_short_desc.setText(product.Desc);
		
		imgLoader = new ImageLoader(this);
		int loader = R.drawable.loader;
		String imageFile = product.IconFile;
		ImageView product_imageView = (ImageView)findViewById(R.id.imageView);
		imgLoader.DisplayImage(imageFile, loader, product_imageView);
		
		
		final Button button = (Button) findViewById(R.id.detail_install);
        button.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                // Perform action on click
            }
        });
    }
}
